# toplevel.py

import functools

from Tkinter import *
import ttk

from ot_simulator.tk_gui import renderer

class toplevel(Toplevel):
    @classmethod
    def obj_editor(cls, obj, master = None, **kw):
        tl = cls(master, **kw)
        #print "toplevel.obj_editor:", "toplevel", tl
        tl.resizable(*renderer.obj_renderer(tl).render_obj(obj))

    @classmethod
    def method_caller(cls, input_fields, button_text, command, master = None,
                      **kw):
        tl = cls(master, **kw)
        tl.resizable(*renderer.obj_renderer(tl)
                        .render_method(input_fields, button_text,
                                       functools.partial(command, tl)))

